package com.lkm.app_ui.help;

import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.os.Looper;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lkm.app_ui.AppConst;
import com.lkm.app_ui.R;
import com.lkm.comlib.help.ViewUIHelp;
import com.lkm.comlib.ui.BaseFragmentActivity;
import com.lkm.javatool.StringHelp;



public class AppUIHelp {

    public static void inputUI(TextView tv_code) {
        AnimationDrawable mFrameAnimation = new AnimationDrawable();
        mFrameAnimation.addFrame(tv_code.getResources().getDrawable(R.drawable.bg_corners_ccc_12), 300);
        mFrameAnimation.addFrame(tv_code.getResources().getDrawable(R.drawable.bg_corners_white_12), 300);
        tv_code.setBackground(mFrameAnimation);
        mFrameAnimation.start();
    }

    public static void tryShowTipsLong(String tips) {
        tryShowTips(Toast.LENGTH_LONG, tips);
    }

    public static void tryShowTipsSHORT(String tips) {
        tryShowTips(Toast.LENGTH_SHORT, tips);
    }

    public static void tryShowTips( int duration, String tips) {
        if(StringHelp.isEmpty(tips))return;
        AppConst.mainHandler.post(new Runnable() {
            @Override
            public void run() {
                
                Toast mToast = Toast.makeText(AppConst.getApplication(), "",
                        duration);
                ViewGroup layout = (ViewGroup) mToast.getView();
                int vcount = layout.getChildCount();
                for (int i = 0; i < vcount; i++) {
                    View v = layout.getChildAt(i);
                    if (v instanceof TextView) {
                        TextView tv = (TextView) v;
                        tv.setTextSize(32);
                    }
                }

                mToast.setGravity(Gravity.CENTER, 0, 0);
                mToast.setText(tips);
                mToast.show();

            }
        });

    }
}
